import { _decorator, Component, Node, director, EventTouch, v3 } from 'cc';
import { DataManager } from '../Public/DataManager';
const { ccclass, property } = _decorator;

@ccclass('Main')
export class Main extends Component {
    start() {
        DataManager.Instance.xhr=new XMLHttpRequest();
        director.preloadScene('BarrierScene');
        director.preloadScene('PlayScene');
    }

    update(deltaTime: number) {
        
    }
    /**前往其他页面 */
    GotoPage(e:EventTouch)
    {
        const page =this.node.getChildByName(e.target.name);
        page.setPosition(v3());
        if(e.target.name==="Rank")
        {
            try {
                wx.getOpenDataContext().postMessage({event:'getRank',openid:DataManager.Instance.openid});
            } catch (error) {
                console.log('error',error);
            }
        }

    }
    /**选择关卡 */
    SelectLevel()
    {
        director.loadScene(`BarrierScene`);
    }
    /**分享 */
    shareApp()
    {
        wx.shareAppMessage({
            title: "兔跑跑",
            query: `game_user_id=${DataManager.Instance.game_user_id}`
          })
    }
    
}

